package com.usian.admin.controller.v1;

import com.usian.admin.service.ChannelService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author baimugudu
 * @email 2415621370@qq.com
 * @date 2023/8/23 8:52
 */
@RequestMapping("/api/v1/channel")
@RestController
@Api(value = "频道管理" ,tags = "channel", description = "频道管理API")
public class AdChannelController implements AdChannelControllerApi {

    @Autowired
    ChannelService channelService;
    @Override
    @PostMapping("/findAdChannel")
    @ApiOperation(value = "查询频道信息",notes = "根据名称分页查询频道列表")
    @ApiImplicitParam(name = "dto",type ="ChannelDto",value = "查询名称")
    public ResponseResult findAdChannel(@RequestBody ChannelDto channelDto) {
        ResponseResult responseResult = channelService.findAdChannel(channelDto);

        return responseResult;
    }

    @Override
    @PostMapping("/insert")
    @ApiOperation(value = "添加频道信息",notes = "添加频道信息")
    @ApiImplicitParam(name = "adChannel",type ="AdChannel",value = "频道信息")
    public ResponseResult insert(@RequestBody AdChannel adChannel) {
        return channelService.insert(adChannel);

    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改频道信息",notes = "修改频道信息")
    @ApiImplicitParam(name = "adChannel",type ="AdChannel",value = "频道信息")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return channelService.update(adChannel);

    }

    @Override
    @DeleteMapping("/del/{id}")
    @ApiOperation(value = "删除频道信息",notes = "删除频道信息")
    @ApiImplicitParam(name = "id",type ="Integer",value = "频道信息ID")
    public ResponseResult del(@PathVariable Integer id) {
        return channelService.del(id);
    }
}
